<?php
set_time_limit(0);
include("class.base.php");
if (!$sess = sisse_logitud()) { header("Location: index.php"); die(); }
if (isset($_GET["path"])) {
	$_GET["path"] = str_replace("..", "", $_GET["path"]);
	if (!strstr($_GET["path"], 'AUDIO_PATH/')) {
		header("HTTP/1.0 404 Not Found"); die();
	}
	include("conf.php");
	$fullImagePath = str_replace('AUDIO_PATH/', AUDIO_PATH, $_GET["path"]);
	$originalFileName = array_reverse(explode("/", $fullImagePath));
	if (!file_exists("wav_audio/".$originalFileName[0]) || filemtime($fullImagePath) > filemtime("wav_audio/".$originalFileName[0])) {
		exec("cp ".$fullImagePath." wav_audio");
	}
	exec("touch wav_audio/".$originalFileName[0]);
	header("Location: wav_audio/".$originalFileName[0]);
}
?>